/*     */ package com.umeng.newxp.view.widget;
/*     */ 
/*     */ import android.content.Context;
/*     */ import android.view.View;
/*     */ import android.widget.LinearLayout;
/*     */ import android.widget.LinearLayout.LayoutParams;
/*     */ import android.widget.RelativeLayout;
/*     */ import android.widget.RelativeLayout.LayoutParams;
/*     */ import com.umeng.common.Log;
/*     */ import com.umeng.common.util.j;
/*     */ import com.umeng.newxp.Promoter;
/*     */ import com.umeng.newxp.view.GridTemplateConfig;
/*     */ import java.util.ArrayList;
/*     */ import java.util.List;
/*     */ 
/*     */ public class a extends RelativeLayout
/*     */ {
/*     */   private static final String a = "GridPage";
/*     */   private a b;
/*     */   private GridTemplateConfig c;
/*     */   private Context d;
/*  23 */   private int e = 0;
/*     */   private List<LinearLayout> f;
/*     */ 
/*     */   public a(Context paramContext, a parama, GridTemplateConfig paramGridTemplateConfig)
/*     */   {
/*  28 */     super(paramContext);
/*  29 */     this.d = paramContext;
/*  30 */     new j(this.d);
/*  31 */     this.b = parama;
/*  32 */     this.c = paramGridTemplateConfig;
/*  33 */     this.f = new ArrayList();
/*     */ 
/*  35 */     a();
/*     */   }
/*     */ 
/*     */   private void a() {
/*  39 */     int i = this.b.a();
/*     */ 
/*  41 */     int j = this.c.numColumns;
/*  42 */     int k = j.a(this.c.verticalSpacing);
/*     */ 
/*  44 */     Log.c("GridPage", "GridPage init params numColums=" + j + "   verticalSpacing=" + k);
/*     */ 
/*  46 */     int m = i % j == 0 ? i / j : i / j + 1;
/*     */ 
/*  48 */     int n = 0;
/*     */ 
/*  50 */     for (int i1 = 0; i1 < m; i1++) {
/*  51 */       LinearLayout localLinearLayout = new LinearLayout(this.d);
/*  52 */       RelativeLayout.LayoutParams localLayoutParams = new RelativeLayout.LayoutParams(
/*  53 */         -1, -2);
/*  54 */       localLinearLayout.setId(10 + i1);
/*  55 */       if (i1 > 0) localLayoutParams.addRule(3, localLinearLayout.getId() - 1);
/*     */ 
/*  57 */       if ((k > 0) && (i1 > 0)) localLayoutParams.topMargin = k;
/*     */ 
/*  59 */       localLinearLayout.setLayoutParams(localLayoutParams);
/*  60 */       localLinearLayout.setOrientation(0);
/*     */ 
/*  62 */       int i2 = n;
/*  63 */       for (int i3 = i2; i3 < i2 + j; i3++)
/*     */       {
/*  65 */         RelativeLayout localRelativeLayout = new RelativeLayout(this.d);
/*  66 */         LinearLayout.LayoutParams localLayoutParams1 = new LinearLayout.LayoutParams(
/*  67 */           -1, -1);
/*  68 */         localLayoutParams1.weight = 1.0F;
/*  69 */         localRelativeLayout.setLayoutParams(localLayoutParams1);
/*     */ 
/*  71 */         if (n++ < i) {
/*  72 */           View localView = this.b.a(i3);
/*  73 */           localRelativeLayout.addView(localView);
/*     */         }
/*     */ 
/*  76 */         localLinearLayout.addView(localRelativeLayout);
/*     */       }
/*  78 */       this.f.add(localLinearLayout);
/*     */ 
/*  80 */       addView(localLinearLayout);
/*     */ 
/*  82 */       this.e = i;
/*     */     }
/*     */   }
/*     */ 
/*     */   public void a(boolean paramBoolean) {
/*  87 */     if (!paramBoolean) {
/*  88 */       if (this.e != this.b.a()) {
/*  89 */         removeAllViews();
/*  90 */         a();
/*  91 */         Log.c("GridPage", "data has changed..");
/*     */       } else {
/*  93 */         Log.c("GridPage", "data has no changed..");
/*     */       }
/*     */     } else { removeAllViews();
/*  96 */       Log.c("GridPage", "pre cast change page.." + getChildCount());
/*  97 */       a();
/*  98 */       Log.c("GridPage", "cast change page.." + getChildCount()); }
/*     */   }
/*     */ 
/*     */   public static abstract class a
/*     */   {
/*     */     List<Promoter> b;
/*     */     a.b c;
/*     */ 
/*     */     public a(List<Promoter> paramList, a.b paramb)
/*     */     {
/* 109 */       this.b = paramList;
/* 110 */       this.c = paramb;
/*     */     }
/*     */ 
/*     */     public int a() {
/* 114 */       return this.c.b;
/*     */     }
/*     */ 
/*     */     public View a(int paramInt)
/*     */     {
/* 124 */       int i = paramInt + this.c.a;
/* 125 */       return a(paramInt, i, (Promoter)this.b.get(i));
/*     */     }
/*     */ 
/*     */     public abstract View a(int paramInt1, int paramInt2, Promoter paramPromoter);
/*     */   }
/*     */ 
/*     */   public static class b
/*     */   {
/*     */     public int a;
/*     */     public int b;
/*     */     public int c;
/*     */     public int d;
/* 145 */     public boolean e = false;
/*     */ 
/* 147 */     public boolean f = false;
/*     */ 
/*     */     public b(int paramInt1, int paramInt2) {
/* 150 */       this.a = paramInt1;
/* 151 */       this.b = paramInt2;
/* 152 */       this.d = (paramInt1 + paramInt2 - 1);
/*     */     }
/*     */   }
/*     */ }

/* Location:           C:\Users\Administrator\Desktop\umeng_sdk.jar
 * Qualified Name:     com.umeng.newxp.view.widget.a
 * JD-Core Version:    0.6.2
 */